package com.supconit.ai.json;

import com.google.gson.Gson;
import com.google.gson.JsonElement;

import java.util.HashMap;
import java.util.Map;

public class JsonUtils {

    public static  String getMessage(){
        String message="{\n" +
                "    \"requestId\": \"f29bb2a6-5f41-9822-9b71-8b863320b88e\",\n" +
                "    \"usage\": {\n" +
                "        \"input_tokens\": 538,\n" +
                "        \"output_tokens\": 101,\n" +
                "        \"total_tokens\": 639,\n" +
                "        \"image_tokens\": 366\n" +
                "    },\n" +
                "    \"output\": {\n" +
                "        \"choices\": [\n" +
                "            {\n" +
                "                \"finish_reason\": \"stop\",\n" +
                "                \"message\": {\n" +
                "                    \"role\": \"assistant\",\n" +
                "                    \"content\": [\n" +
                "                        {\n" +
                "                            \"text\": \"```json\\n{\\n  \\\"answer\\\": true,\\n  \\\"description\\\": \\\"电子狗发现此区域存在人员聚集。\\\",\\n  \\\"sum\\\": 3,\\n  \\\"size\\\": {\\n    \\\"width\\\": 640,\\n    \\\"height\\\": 427\\n  },\\n  \\\"localtion\\\": {\\n    \\\"x\\\": 130,\\n    \\\"y\\\": 15,\\n    \\\"w\\\": 508,\\n    \\\"h\\\": 412\\n  }\\n}\\n```\"\n" +
                "                        }\n" +
                "                    ]\n" +
                "                }\n" +
                "            }\n" +
                "        ]\n" +
                "    }\n" +
                "}";
        return message;

    }

    public static void main(String[] args){
        Gson gson = new Gson();
        String msg = getMessage();
        QWenResultObj resultObj = gson.fromJson(msg, QWenResultObj.class);
        String text = resultObj.getOutput().getChoices().get(0).getMessage().getContent().get(0).getText();
        String result = Shuffle.shuffle(text);
        //System.out.println("result:"+result);
        HashMap map = gson.fromJson(result, HashMap.class);
        System.out.println("map result:"+map);
    }
}
